﻿using System;
using HttpApiGateway.Model;
using RpcHelper.Validate;
using Wedonek.RpcStore.Gateway.Interface;
using Wedonek.RpcStore.Gateway.Model;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Gateway.Controller
{
    /// <summary>
    /// 任务计划
    /// </summary>
    internal class TaskPlanController : HttpApiGateway.ApiController
    {
        private readonly IAutoTaskPlanService _Service;
        public TaskPlanController(IAutoTaskPlanService service)
        {
            this._Service = service;
        }
        /// <summary>
        /// 添加任务计划
        /// </summary>
        /// <param name="plan"></param>
        /// <returns></returns>
        public Guid Add(AddTaskPlan plan)
        {
            return this._Service.Add(plan);
        }
        /// <summary>
        /// 删除任务计划
        /// </summary>
        /// <param name="id"></param>
        public void Delete([NullValidate("rpc.task.plan.Id.null")] Guid id)
        {
            this._Service.Delete(id);
        }
        /// <summary>
        /// 获取任务计划
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public AutoTaskPlan Get([NullValidate("rpc.task.plan.Id.null")] Guid id)
        {
            return this._Service.Get(id);
        }
        /// <summary>
        /// 获取任务计划列表
        /// </summary>
        /// <param name="taskId"></param>
        /// <returns></returns>
        public AutoTaskPlan[] Gets([NullValidate("rpc.task.Id.null")] Guid taskId)
        {
            return this._Service.Gets(taskId);
        }
        /// <summary>
        /// 更新任务计划
        /// </summary>
        /// <param name="set"></param>
        public void Set(GuidParam<TaskPlanSet> set)
        {
            this._Service.Set(set.Id, set.Param);
        }
        /// <summary>
        /// 启用或禁用任务计划
        /// </summary>
        /// <param name="set"></param>
        public void SetIsEnable(GuidParam<bool> set)
        {
            this._Service.SetIsEnable(set.Id, set.Param);
        }
    }
}
